package com.uinnova.springboot.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.context.annotation.Configuration;

@Aspect
@Configuration
public class AopExample {
//
//    @Pointcut(value="@annotation(AopAnnotation)")
//     public void annotation(){
//    }
//
//    @Around(value = "annotation()&&@annotation(test)")
//    public void  ceshiAopAnnotation(ProceedingJoinPoint proceedingJoinPoint,AopAnnotation test) throws  Throwable{
//        System.out.println("我已经进来开始测试了");
//        System.out.println(test.value());
//    }

    @Pointcut(value="@annotation(AopAnnotation)")
    public void before(){
    }

    @Before(value = "before()")
    public void ceshiBefore(JoinPoint joinPoint){
        System.out.println("测试-aop-before");
    }

    @After(value = "before()")
    public void ceshiAfter(){
        System.out.println("测试-aop-after");
    }

    @AfterReturning(value = "before()",returning = "aopDTO")
    public void ceshiAfterReturning(JoinPoint joinPoint,AopDTO aopDTO){
        aopDTO.setName("wanggang1");
        System.out.println("我来对返回值进行处理"+aopDTO.getName());
    }
//
//    @Around(value = "before()")
//    public Object ceshiAround(ProceedingJoinPoint proceedingJoinPoint){
//        System.out.println("测试aop-around之前");
//        return   11111;
//    }

    @AfterThrowing(value = "before()",throwing = "exception")
    public void testAfterThrowing(JoinPoint joinPoint,Throwable exception){
        System.out.println(exception.getMessage());

    }





}
